(function() {
    //获取DOM节点
    var ulEl = document.getElementById('goods-ul');
    var leftbtn = document.getElementById('goods-left-btn');
    var rightbtn = document.getElementById('goods-right-btn');

    //序号
    var idx = 0;

    //右按钮
    rightbtn.addEventListener('click',function() {
        idx++;
        if(idx > 6) {
            ulEl.style.left = -6 * 368 + 'px';
            idx = 6;
        }else {
            ulEl.style.left = -idx * 368 + 'px';
        }
    },false)
    //左按钮
    leftbtn.addEventListener('click',function() {
        idx--;
        if(idx < 0) {
            ulEl.style.left = -0 * 368 + 'px';
            idx = 0;
        }else {
            ulEl.style.left = -idx * 368 + 'px';
        }
    },false)
})()